/**
 * 
 */
var start = false;
var stratX=0, startY=0;
var ctx;
function drawing(){
	
	document.getElementById('canvas').onmousemove = pic;
	document.getElementById('canvas').onmouseup = set;
	ctx = document.getElementById('canvas').getContext('2d');
}

function set(e){
	var lc;
	var lw;
	start = !start;
	startX = e.x-7;
	startY = e.y-8;
	//선그리기 시작점 설정
	if(start){
		ctx.beginPath();
		ctx.moveTo(startX, startY);
		lc = document.getElementById('lineColor');
		lw = document.getElementById('lineWidth');
		ctx.strokeStyle = lc.value;
		ctx.lineWidth = lw.value;
	}else{
		ctx.closepath();
	}
}

function pic(e){
	var d = document.getElementById('result');
	var x= e.x;
	var y =e.y;
	d.innerHTML = 'x=' + x +',y='+y;
	if(start){
		ctx.lineTo(x,y);
		ctx.stroke();
	}
}

